﻿
@{
    ViewBag.Title = "Setting";
}

<div class="container" style="min-height:500px;">

    <div class="row">
        <div class="col-xs-3">
            <ul class="nav default-sidenav">
                <li class="active">
                    @Html.ActionLink("基本资料", "Setting", "Student", new { @class = "fa fa-cogs" })
                </li>
                <li>
                    @Html.ActionLink("修改密码", "ChangePassword", "Student", new { @class = "fa fa-wrench" })
                </li>
            </ul>

        </div>
        <div class="col-xs-9">
            <div class="page-header">
                <h1><i class="fa fa-cogs"></i> 基本资料</h1>
            </div>
            <div class="page-content row">
                <form class="form-horizontal" role="form" onsubmit="return false;">

                    <!-- username -->
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">账号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="username" placeholder="请输入账号" value="@ViewBag.user.UserName" disabled="disabled">
                            <span style="display:none" class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
                        </div>
                    </div>

                    <!-- phone -->
                    <div class="form-group">
                        <label for="phone" class="col-sm-2 control-label">手机</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="phone" value="@ViewBag.user.Phone">
                            <span style="display:none" class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
                        </div>
                    </div>

                    <!-- Email -->
                    <div class="form-group">
                        <label for="email" class="col-sm-2 control-label">邮箱</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="email" value="@ViewBag.user.Email">
                            <span style="display:none" class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
                        </div>
                    </div>

                    <!-- Buttons -->
                    <div class="form-group">
                        <!-- Buttons -->
                        <div class="col-md-5 col-md-offset-2">
                            <button class="btn" id="btn-reg" onclick="changeInfo()">
                                确认修改
                            </button>

                        </div>
                    </div>
                </form>


                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title" id="myModalLabel">提示</h4>
                            </div>
                            <div class="modal-body" id="resultContent">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">确定</button>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    $("#phone").change(change);
    $("#email").change(change);

    function change() {
        var input = $(this);
        if (input.val() != '') {
            input.parent().parent().removeClass('has-feedback');
            input.parent().parent().removeClass('has-warning');
            input.parent().children('span').hide();
        }
    }

    function changeInfo() {
        var phone = $("#phone").val();
        var email = $("#email").val();
        $.ajax({
            url: '@Url.Action("ChangInfo","Account")',
            type: 'post',
            data: { phone: phone, email: email },
            error: function (result) {
                $("#resultContent").html(result.responseText);
                $('#myModal').modal('show');
            },
            success: function () {
                $("#resultContent").html("修改成功");
                $('#myModal').modal('show');
            }
        });
    }
</script>